<style scoped>
    .expand-row{
        margin-bottom: 16px;
    }
</style>
<template>
    <div>
        <Table border :columns="columns1" :data="data1"></Table>
    </div>
</template>
<script>
	import { ipcRenderer } from "electron";
    export default {
        data(){
            return {
                total:1,
                currenPage:1,
                columns1:[
                {
                    title:'币种',
                    key:'bz'
                },{
                    title:'买入市场',
                    key:'mrsc'
                },{
                    title:'卖出市场',
                    key:'mcsc'
                },{
                    title:'数量',
                    key:'num'
                },{
                    title:'预设利润率(%)',
                    render:(h,params) => {
                        let col = '';
                        if(params.row.yslrl < 0){
                            col = '#ed3f14';
                        }
                        return h('div',[
                            h('span',{
                                style:{
                                    color:col
                                }
                            },params.row.yslrl)
                        ])
                    }
                },{
                    title:'期望利润率(%)',
                    render:(h,params) => {
                        let col = '';
                        if(params.row.qwlrl < 0){
                            col = '#ed3f14';
                        }
                        return h('div',[
                            h('span',{
                                style:{
                                    color:col
                                }
                            },params.row.qwlrl)
                        ])
                    }
                },{
                    title:'实际利润率(%)',
                    render:(h,params) => {
                        let col = '';
                        if(params.row.sjlrl < 0){
                            col = '#ed3f14';
                        }
                        return h('div',[
                            h('span',{
                                style:{
                                    color:col
                                }
                            },params.row.sjlrl)
                        ])
                    }
                },{
                    title:'利润额(美元)',
                    render:(h,params) => {
                        let col = '';
                        if(params.row.lre < 0){
                            col = '#ed3f14';
                        }
                        return h('div',[
                            h('span',{
                                style:{
                                    color:col
                                }
                            },params.row.lre)
                        ])
                    }
                },{
                    title:'订单状态',
                    render:(h,params) => {
                        let fontcolor = '';
                        if(params.row.status=='已完成'){
                            fontcolor = 'green';
                        }
                        if(params.row.status=='未完成'){
                            fontcolor = '#ed3f14';
                        }
                        return h('div',[
                            h('span',{
                                style:{
                                    color:fontcolor
                                }
                            },params.row.status)
                        ])
                    }
                },{
                    title:'时间',
                    key:'time'
                },{
                    title:'操作',
                    render:(h,params) => {
						if(params.row.status!=='已确认'){
							return h('Poptip', {
								props: {
									confirm: true,
									title: `您确定要确认这条交易信息吗?`,
									transfer: true
								},
								on: {
									'on-ok': () => {
										this.confirmInfo(params.row);
									}
								}
							}, [
								h('Button', {
									props:{
										type:'primary'
									}
								}, '手工确认')
							]);
						}else{
							return '';
						}
                    }
                }],
                data1:[],
            }
        },
        props: {
            row: Array
        },
        created(){
            this.data1 = this.row;
			ipcRenderer.on('confirmData',(err,msg)=>{
				if(msg=='ok'){
					this.$Message.success("手动确认成功");
				}
			})
        },
        methods:{
			getMessage: function(event, type) {
			  ipcRenderer.send(event, type);
			},
            confirmInfo:function(data){
				data.status = '已确认';
				this.$emit('increment',data);
				this.getMessage('confirmData',data);
			}
        },
		destroyed() {
			ipcRenderer.removeAllListeners("confirmData");
		}
    };
</script>